package com.alibaba.citrus.cr.sales.plan.functions.salesplanscitem;

import com.alibaba.citrus.cr.common.util.SpringContextUtil;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.SalesPlanScItemPageQueryRequest;
import com.alibaba.citrus.cr.sales.plan.repository.SalesPlanScItemRepository;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.*;
import com.alibaba.citrus.cr.sales.plan.sdo.SalesPlanScItemSDO;
import com.alibaba.cz.base.tool.page.PageResult;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author wangyibing
 */
public class SalesPlanScItemEntity {
    @Getter
    @Setter
    private SalesPlanScItemSDO salesPlanScItemSDO;

    private static SalesPlanScItemRepository salesPlanScItemRepository;

    static {
        salesPlanScItemRepository = SpringContextUtil.getBean(SalesPlanScItemRepository.class);
    }

    public static SalesPlanScItemEntity of(SalesPlanScItemSDO salesPlanScItemSDO) {
        SalesPlanScItemEntity entity = new SalesPlanScItemEntity();
        entity.setSalesPlanScItemSDO(salesPlanScItemSDO);
        return entity;
    }


    public String doCreate() {
        return salesPlanScItemRepository.createSalesPlanScItem(salesPlanScItemSDO);
    }

    public PageResult<List<SalesPlanScItemSDO>> doPageQuery(SalesPlanScItemPageQueryRequest planPageQueryRequest) {
        return salesPlanScItemRepository.pageQuerySalesPlanScItemList(planPageQueryRequest);
    }

    public Integer doEdit() {
        return salesPlanScItemRepository.editSalesPlanScItem(salesPlanScItemSDO);
    }

}
